/*
	This file is part of Erosion, a clone of Qix
	Copyright (c) 2009 Bill Whitacre

	Permission is hereby granted, free of charge, to any person obtaining a copy
	of this software and associated documentation files (the "Software"), to deal
	in the Software without restriction, including without limitation the rights
	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
	copies of the Software, and to permit persons to whom the Software is
	furnished to do so, subject to the following conditions:

	The above copyright notice and this permission notice shall be included in
	all copies or substantial portions of the Software.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
	THE SOFTWARE.
*/

#ifndef SYSTEM_CORE_H
#define SYSTEM_CORE_H

#if defined(_MSC_VER)||defined(__WIN32__)
#	include <windows.h>
#endif

#include <stdlib.h>
#include <stdio.h>
#include <GL/gl.h>

#include "keymap.h"

#define RAT_GAMEPAD_DPAD_UP          0x0001
#define RAT_GAMEPAD_DPAD_DOWN        0x0002
#define RAT_GAMEPAD_DPAD_LEFT        0x0004
#define RAT_GAMEPAD_DPAD_RIGHT       0x0008
#define RAT_GAMEPAD_START            0x0010
#define RAT_GAMEPAD_BACK             0x0020
#define RAT_GAMEPAD_LEFT_THUMB       0x0040
#define RAT_GAMEPAD_RIGHT_THUMB      0x0080
#define RAT_GAMEPAD_LEFT_SHOULDER    0x0100
#define RAT_GAMEPAD_RIGHT_SHOULDER   0x0200
#define RAT_GAMEPAD_A                0x1000
#define RAT_GAMEPAD_B                0x2000
#define RAT_GAMEPAD_X                0x4000
#define RAT_GAMEPAD_Y                0x8000

#ifdef __cplusplus
extern "C" {
#endif

int rat_start_system_core(const char *name,unsigned int vw,
	unsigned int vh,unsigned int vbpp,int vfs,int resizeable);
void rat_stop_system_core();

void rat_video_size(unsigned int *vw,unsigned int *vh);

int rat_handle_events();
int rat_update_video();

void rat_get_mouse_position(float *x,float *y);
int rat_is_key_down(RAT_KEY_CODE key);
int rat_is_mouse_down(int button);

int rat_appterm_event();
int rat_resized_event();

void rat_get_key_buffer(unsigned char *keys);

int rat_is_controller_connected(int controller);
int rat_is_button_pressed(int controller,unsigned button);

unsigned char rat_left_trigger(int controller);
unsigned char rat_right_trigger(int controller);

void rat_left_thumbstick(int controller,short *x,short *y);
void rat_right_thumbstick(int controller,short *x,short *y);

void rat_set_rumble(int controller,unsigned short left,unsigned short right);

#ifdef __cplusplus
};
#endif

#endif
